package de.ff7rl.ui;

import java.awt.Color;

public class TerminalData {

  private static char[][] copyArrayArray(final char[][] theArryArray) {
    final char[][] copy = new char[theArryArray.length][];
    for (int i = 0; i < theArryArray.length; i++) {
      copy[i] = new char[theArryArray[i].length];
      for (int j = 0; j < theArryArray[i].length; j++) {
        copy[i][j] = theArryArray[i][j];
      }
    }
    return copy;
  }

  private static Color[][] copyArrayArray(final Color[][] theArryArray) {
    final Color[][] copy = new Color[theArryArray.length][];
    for (int i = 0; i < theArryArray.length; i++) {
      copy[i] = new Color[theArryArray[i].length];
      for (int j = 0; j < theArryArray[i].length; j++) {
        copy[i][j] = theArryArray[i][j];
      }
    }
    return copy;
  }

  private final Color foregroundColor;
  private final Color backgroundColor;
  private final char[][] characters;
  private final Color[][] backgroundColors;
  private final Color[][] foregroundColors;

  public TerminalData(final char[][] theCharacters, final Color theForegroundColor, final Color theBackgroundColor,
      final Color[][] theForegroundColors, final Color[][] theBackgroundColors) {
    characters = theCharacters;
    foregroundColor = theForegroundColor;
    backgroundColor = theBackgroundColor;
    foregroundColors = theForegroundColors;
    backgroundColors = theBackgroundColors;
  }

  public TerminalData(final TerminalData theTerminalData) {
    this(copyArrayArray(theTerminalData.getCharacters()), theTerminalData.getForegroundColor(), theTerminalData
        .getBackgroundColor(), copyArrayArray(theTerminalData.getForegroundColors()), copyArrayArray(theTerminalData
        .getBackgroundColors()));
  }

  public Color getBackgroundColor() {
    return backgroundColor;
  }

  public Color[][] getBackgroundColors() {
    return backgroundColors;
  }

  public char[][] getCharacters() {
    return characters;
  }

  public Color getForegroundColor() {
    return foregroundColor;
  }

  public Color[][] getForegroundColors() {
    return foregroundColors;
  }

}
